package com.example.data.factory.entity.entity;

import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner ( System.in );
        int n = scan.nextInt ();
        String[] arr = new String[n];
        for (int i = 0; i < n; i++) {
            arr[i] = scan.next ();
        }
        Arrays.sort ( arr, (x, y) -> (y + x).compareTo ( x + y ) );

        StringBuilder result = new StringBuilder ();
        for (int i = 0; i < n; i++) {
            result.append ( arr[i] );
        }
        System.out.println ( result );
    }
}
